#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
    cout << "process running..." << endl;
    sleep(1);
    // ThreadPool<Task> *tp = new ThreadPool<Task>(5);
    ThreadPool<Task>::GetInstance()->Start();
    srand(time(nullptr) ^ getpid());

    while(true)
    {
        //1. 构建任务
        int x = rand() % 10 + 1;
        usleep(10);
        int y = rand() % 9;
        char op = opers[rand() % opers.size()];
        
        Task t(x, y, op);
        ThreadPool<Task>::GetInstance()->Push(t);
        //2. 交给线程池处理
        printf("main thread push a task: %s\n", t.GetTask().c_str());
        sleep(1);
    }
}